<template>
  <div class="ma-content-block lg:flex justify-between">
    <!-- CRUD 组件 -->
    <sa-table ref="crudRef" :options="options" :columns="columns" :searchForm="searchForm">
      <!-- 搜索区 tableSearch -->
      <template #tableSearch>
        <a-col :sm="8" :xs="24">
          <a-form-item field="room_id" label="直播间ID">
            <a-input v-model="searchForm.room_id" placeholder="请输入直播间ID" allow-clear />
          </a-form-item>
        </a-col>
        
      </template>

      <!-- Table 自定义渲染 -->
      <!-- 状态列 -->
      
      <template #operationAfterExtend="{ record }">
        <a-link @click="open(record)" type="primary">查看明细</a-link>
      </template>
      
    </sa-table>

    <!-- 编辑表单 -->
    <signNameList ref="signNameRef" />
    <!-- 查看表单 -->
  </div>
</template>

<script setup>
import { onMounted, ref, reactive } from 'vue'
import api from '@/api/marketing/banner'
import signNameList from './components/signNameList.vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const crudRef = ref()
const signNameRef = ref()
// 搜索表单
const searchForm = ref({
  room_id:  route.query.room_id || '',
})


// SaTable 基础配置
const options = reactive({
  api: api.CallRecordList,
  rowSelection: { showCheckedAll: true },
})

// SaTable 列配置
const columns = reactive([
  { title: '直播间ID', dataIndex: 'room_id', width:180 },
  { title: '直播间名称', dataIndex: 'name', width:180 },
  { title: '签到标识', dataIndex: 'sign_check', width: 180 },
  { title: '第几次点名', dataIndex: 'layer', width: 180 },
  { title: '持续时间', dataIndex: 'time', width: 180 },
  { title: '签到人数', dataIndex:'sign_total', width:180},
  { title: '发起时间', dataIndex: 'add_time', width: 180 },
])

const open = (record) => {
  signNameRef.value?.open(record)
}

// 页面数据初始化
const initPage = async () => {}

// SaTable 数据请求
const refresh = async () => {
  crudRef.value?.refresh()
}

// 页面加载完成执行
onMounted(async () => {
  initPage()
  refresh()
})
</script>
